package com.yuren.codecrushlearn.Q5200;

import java.util.ArrayList;
import java.util.List;

/**
 * Created with Intellij IDEA.
 * Description:
 * 二维Bruce Force算法
 * @author 10204
 * @date 2025-05-03 23:43
 */
public class Q5243 {
    public List<int[]> superBF(char[][] big, int bigN, int bigM, char[][] small, int smallN, int smallM) {
        List<int[]> positions = new ArrayList<>();
        for (int i = 0; i <= bigN - smallN; i++) {
            for (int j = 0; j <= bigM - smallM; j++) {
                if (isMatch(big, small, i, j, smallN, smallM)) {
                    positions.add(new int[]{i, j});
                }
            }
        }
        return positions;
    }

    public boolean isMatch(char[][] big, char[][] small, int row, int col, int smallN, int smallM) {
        for (int i = 0; i < smallN; i++) {
            for (int j = 0; j < smallM; j++) {
                if (big[row + i][col + j] != small[i][j]) {
                    return false;
                }
            }
        }
        return true;
    }
}
